#ifndef _NEPTUNER_SYMBOLYZER_H_
#define _NEPTUNER_SYMBOLYZER_H_

#include "Scope.h"
#include "Symbol.h"
#include "Location.h"
#include "Scubserver.h"

class Symbolyzer: public Scubserver
{
public:
	enum Mode
	{
		eSymbolyzerInitial,
		eSymbolyzerTypedef,
		eSymbolyzerDataType,
		eSymbolyzerVariable
	};
        
	Mode		m_eMode;
	Scope*		m_pxLookaheadScope;

	Mode		m_eModeHistory; 
	Scope*		m_pxImmediateScope;
	std::string	m_sLastSymbol;
	//TODO: Possible bug here? when there are multiple scopes? There is only one Symbolyzer per Scuba...

	bool		m_bInsideFunction;
	bool		m_bFuncDefActive;

private:
    void onEntryParen(Scope& inNewScope, Scope& inOldScope);
    void onEntryBlock(Scope& inNewScope, Scope& inOldScope);

	bool isDataType(std::string& s);

	void matchDataType(Token& inToken);
	void matchVariable(Token& inToken);
	void matchTypedef(Token& inToken);

	void defineSymbol(Symbol in_xSymbol, Scope* in_pxScope);
	void checkSymbol(std::string s, Symbol& in_xSymbol);

public:
    void onNewToken(Scope& inScope, Token& inToken);
    void onScopeEntry(Scope& inNewScope, Scope& inOldScope);
    void onScopeExit(Scope& inNewScope, Scope& inOldScope);

    Symbolyzer();
    ~Symbolyzer(void);


};

#endif
